package com.tuanzi.loan.web.bean.family;

import com.tuanzi.loan.vo.request.family.LoanApiOrderRepaymentSearchRequest;
import com.tuanzi.loan.vo.response.family.LoanApiOrderRepaymentSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.family.LoanApiOrderRepaymentLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;

/**
* @Description:    全流程还款计划明细
* @Author:         xionghao
* @CreateDate:      2018-10-08
*/
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanApiOrderRepaymentBean
        extends JSFListingBean<LoanApiOrderRepaymentSearchRequest,LoanApiOrderRepaymentSearchResponse>{
    private static final long serialVersionUID = 5260518056287502058L;


    @PostConstruct
    private void init() {
        initLazyDataModel();
    }

    private void initLazyDataModel() {
        String OrderId = getParamFromRequest("id");
        if (StringUtils.isNotBlank(OrderId)){
            $=new LoanApiOrderRepaymentSearchRequest();
            $.setOrderId(Long.valueOf(OrderId));
            lazyDataModel = new LoanApiOrderRepaymentLazyDataModel($);
        }else{
            addErrorMessage("未获取到需要查询的订单，请重新查询");
        }
    }
}
